fromView and toView
转场动画中时常会出现 fromView 和 toView 这一组相对的概念
fromView:跳转前的视图
toView:跳转后的视图
当然这两个视图是相对的,
比如A present to B ,此时 A = fromView , B = toView
然而B dismiss to A ,此时 B = fromView , A = toView
所以fromView和toView不是固定且一成不变的,会随着动画的执行和结束发生变化,扮演不同的角色
presentedViewController and presentingViewController
听过 fromView 和 toView ,想必 presentedViewController 和 presentingViewController也不会太陌生,这也是一组相对概念,而且容易与第一组混淆。
不同之处在于 presentedViewController 和 presentingViewController 的身份不受present影响,简单说还是上面的例子
比如A present to B ,此时 A = presentedViewController , B = presentingViewController
然而B dismiss to A ,此时 A = presentedViewController , B = presentingViewController
modalPresentationStyle
系统提供的一个present时动画的枚举类型
typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,
UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,
UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),
UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),
UIModalPresentationOverFullScreen NS_ENUM_AVAILABLE_IOS(8_0),
UIModalPresentationOverCurrentContext NS_ENUM_AVAILABLE_IOS(8_0),
UIModalPresentationPopover NS_ENUM_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED,
UIModalPresentationBlurOverFullScreen __TVOS_AVAILABLE(11_0) __IOS_PROHIBITED __WATCHOS_PROHIBITED,
UIModalPresentationNone NS_ENUM_AVAILABLE_IOS(7_0) = -1,
};
其中可以自定义动画效果的只有两种:FullScreen和Custom,两者的区别在于FullScreen会移除fromView,而Custom不会。
UIViewControllerTransitioningDelegate
transitionFromViewController
通常的使用场景是 在多个Child ViewController之间切换.
[self transitionFromViewController:<#(nonnull uiviewcontroller="" *)#="">
toViewController:<#(nonnull uiviewcontroller="" *)#="">
duration:<#(nstimeinterval)#>
options:<#(uiviewanimationoptions)#>
animations:<#^(void)animations#>
completion:<#^(bool finished)completion#="">];
#^(bool>#^(void)animations#>#(uiviewanimationoptions)#>#(nstimeinterval)#>#(nonnull>#(nonnull>